package log

import (
	"context"

	"gitee.com/mkwchecking/sr-core/log/ilog"
)

type YLogKey struct{}

func WithCtx(ctx context.Context, logger ilog.Logger) context.Context {
	return context.WithValue(ctx, YLogKey{}, logger)
}

func FromCtx(ctx context.Context) (ilog.Logger, bool) {
	val := ctx.Value(YLogKey{})
	if val == nil {
		return nil, false
	}
	logger, ok := val.(ilog.Logger)
	return logger, ok
}
